/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import controlador.ControladorCompra;
import controlador.ControladorTransacoes;
import controlador.ControladorUsuario;
import geracaopdf.ListaProdutosVendidosPorDataPDF;
import geracaopdf.TransacoesNotaDeVendaPDF;
import java.util.ArrayList;
import java.util.Calendar;
import java.sql.Date;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import utils.Cliente;
import utils.Compra;
import utils.Transacoes;
import utils.Usuario;

/**
 *
 * @author Igor
 */
public class PainelDaZonaDeAdministracao extends javax.swing.JPanel {

    /**
     * Creates new form PainelDaZonaDeAdministracao
     */
    ControladorUsuario controladorUsuario = new ControladorUsuario();
    ArrayList<Usuario> usuarios = new ArrayList<Usuario>();
    ControladorTransacoes controladorTransacoes = new ControladorTransacoes();
    ControladorCompra controladorCompras = new ControladorCompra();
    ArrayList<Transacoes> transacoes = new ArrayList<Transacoes>();
    ArrayList<Compra> compras = new ArrayList<Compra>();
    ArrayList<Transacoes> listaProdutosVendidos = new ArrayList<Transacoes>();
    
    Compra compraSelecionada;
    int codigoSelecionado;
    int[] dias = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
    int[] meses = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
    int[] anos = {2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008, 2007, 2006, 2005, 2004, 2003, 2002, 2001, 2000};
    private final DefaultTableModel modelUsuarios;
    String loginSelecionado = "";
    private final DefaultTableModel modelTransacoes;
    private final DefaultTableModel modelCompras;
    private final DefaultTableModel modelProdutosVendidos;

    public PainelDaZonaDeAdministracao() {
        initComponents();

        modelTransacoes = (DefaultTableModel) tabelaTransacoes.getModel();
        modelUsuarios = (DefaultTableModel) tabelaUsuarios.getModel();
        modelCompras = (DefaultTableModel) tabelaCompras.getModel();
        modelProdutosVendidos = (DefaultTableModel) tabelaProdutosVendidos.getModel();

        this.abasUsuario.setEnabledAt(0, true);
        this.abasUsuario.setEnabledAt(1, false);
        this.abasUsuario.setEnabledAt(2, false);
        this.abasUsuario.setEnabledAt(3, false);

        this.campoBuscaCPFCNPJ.setEnabled(false);
        this.campoBuscaID.setEnabled(false);

        this.comboAnoFinal.setEnabled(false);
        this.comboAnoInicial.setEnabled(false);
        this.comboMesFinal.setEnabled(false);
        this.comboMesInicial.setEnabled(false);
        this.comboDiaFinal.setEnabled(false);
        this.comboDiaInicial.setEnabled(false);

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        barraAdministrador = new javax.swing.JToolBar();
        adicionarUsuarios = new javax.swing.JButton();
        editarUsuarios = new javax.swing.JButton();
        editarTransacoes = new javax.swing.JButton();
        produtosVendidos = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        abasUsuario = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        campoLoginUsuario = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        campoSenha = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        confirmaSenha = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        botaoConfirmarUsuario = new javax.swing.JButton();
        cancelarBotao = new javax.swing.JButton();
        comboNivelAcesso = new javax.swing.JComboBox();
        jPanel3 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        campoBuscaLogin = new javax.swing.JTextField();
        buscarCliente = new javax.swing.JButton();
        atualizaCliente = new javax.swing.JButton();
        novoLogin = new javax.swing.JTextField();
        novaSenha = new javax.swing.JTextField();
        novoNivelAcesso = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabelaUsuarios = new javax.swing.JTable();
        selecionaCliente = new javax.swing.JButton();
        removerCliente = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tabelaTransacoes = new javax.swing.JTable();
        jLabel8 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        campoBuscaID = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        campoBuscaCPFCNPJ = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        comboDiaInicial = new javax.swing.JComboBox();
        comboMesInicial = new javax.swing.JComboBox();
        comboAnoInicial = new javax.swing.JComboBox();
        jLabel14 = new javax.swing.JLabel();
        comboDiaFinal = new javax.swing.JComboBox();
        comboMesFinal = new javax.swing.JComboBox();
        comboAnoFinal = new javax.swing.JComboBox();
        checkData = new javax.swing.JCheckBox();
        checkCPFCNPJ = new javax.swing.JCheckBox();
        checkID = new javax.swing.JCheckBox();
        buscarTransacao = new javax.swing.JButton();
        cancelarBusca = new javax.swing.JButton();
        selecionarTransacao = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        tabelaCompras = new javax.swing.JTable();
        selecionarCompra = new javax.swing.JButton();
        removerCompra = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        comboAnoFinalProduto = new javax.swing.JComboBox();
        comboMesFinalProduto = new javax.swing.JComboBox();
        comboDiaFinalProduto = new javax.swing.JComboBox();
        jLabel15 = new javax.swing.JLabel();
        comboAnoInicialProduto = new javax.swing.JComboBox();
        comboMesInicialProduto = new javax.swing.JComboBox();
        comboDiaInicialProduto = new javax.swing.JComboBox();
        buscarProdutosVendidos = new javax.swing.JButton();
        cancelarProdutosVendidos = new javax.swing.JButton();
        jScrollPane4 = new javax.swing.JScrollPane();
        tabelaProdutosVendidos = new javax.swing.JTable();
        gerarListaProdutosVendidos = new javax.swing.JButton();

        barraAdministrador.setOrientation(javax.swing.SwingConstants.VERTICAL);
        barraAdministrador.setRollover(true);

        adicionarUsuarios.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/addCliente.png"))); // NOI18N
        adicionarUsuarios.setText("AdicionarUsuarios");
        adicionarUsuarios.setFocusable(false);
        adicionarUsuarios.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        adicionarUsuarios.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        adicionarUsuarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                adicionarUsuariosActionPerformed(evt);
            }
        });
        barraAdministrador.add(adicionarUsuarios);

        editarUsuarios.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/editClient.png"))); // NOI18N
        editarUsuarios.setText("Editar Usuários");
        editarUsuarios.setFocusable(false);
        editarUsuarios.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editarUsuarios.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editarUsuarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editarUsuariosActionPerformed(evt);
            }
        });
        barraAdministrador.add(editarUsuarios);

        editarTransacoes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/transacoes2.png"))); // NOI18N
        editarTransacoes.setText("Editar Vendas");
        editarTransacoes.setFocusable(false);
        editarTransacoes.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editarTransacoes.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editarTransacoes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editarTransacoesActionPerformed(evt);
            }
        });
        barraAdministrador.add(editarTransacoes);

        produtosVendidos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/produtosVendidos.png"))); // NOI18N
        produtosVendidos.setText("Produtos Vendidos");
        produtosVendidos.setFocusable(false);
        produtosVendidos.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        produtosVendidos.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        produtosVendidos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                produtosVendidosActionPerformed(evt);
            }
        });
        barraAdministrador.add(produtosVendidos);

        jPanel1.setBackground(new java.awt.Color(0, 0, 102));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 8, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel1.setText("Adição de Usuários");

        jLabel2.setText("Login:");

        jLabel3.setText("Senha:");

        jLabel4.setText("Confirme a senha:");

        jLabel5.setText("Nível de acesso:");

        botaoConfirmarUsuario.setText("Confirmar");
        botaoConfirmarUsuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoConfirmarUsuarioActionPerformed(evt);
            }
        });

        cancelarBotao.setText("Cancelar");
        cancelarBotao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelarBotaoActionPerformed(evt);
            }
        });

        comboNivelAcesso.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0 - Usuário Comum", "1 - Usuário Administrador" }));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(159, 159, 159)
                        .addComponent(botaoConfirmarUsuario)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cancelarBotao))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(comboNivelAcesso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jLabel5)
                                .addComponent(jLabel4)
                                .addComponent(jLabel3)
                                .addComponent(jLabel2)
                                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(campoSenha, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
                                .addComponent(campoLoginUsuario)
                                .addComponent(confirmaSenha)))))
                .addContainerGap(782, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(jLabel1)
                .addGap(36, 36, 36)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(campoLoginUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(campoSenha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(confirmaSenha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(comboNivelAcesso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botaoConfirmarUsuario)
                    .addComponent(cancelarBotao))
                .addContainerGap(205, Short.MAX_VALUE))
        );

        abasUsuario.addTab("Adicionar", jPanel2);

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel6.setText("Edição de Usuários");

        jLabel7.setText("Busque pelo login:");

        buscarCliente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/search.png"))); // NOI18N
        buscarCliente.setText("Buscar");
        buscarCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buscarClienteActionPerformed(evt);
            }
        });

        atualizaCliente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/edit.png"))); // NOI18N
        atualizaCliente.setText("Editar");
        atualizaCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                atualizaClienteActionPerformed(evt);
            }
        });

        jLabel9.setText("Digite os novos campos:");

        tabelaUsuarios.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Login", "Senha", "Nível de acesso"
            }
        ));
        jScrollPane1.setViewportView(tabelaUsuarios);

        selecionaCliente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/select.png"))); // NOI18N
        selecionaCliente.setText("Selecionar");
        selecionaCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                selecionaClienteActionPerformed(evt);
            }
        });

        removerCliente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/remove.png"))); // NOI18N
        removerCliente.setText("Remover");
        removerCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removerClienteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7)
                            .addComponent(campoBuscaLogin, javax.swing.GroupLayout.PREFERRED_SIZE, 450, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 492, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(156, 156, 156)
                                .addComponent(buscarCliente)))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(novaSenha, javax.swing.GroupLayout.PREFERRED_SIZE, 387, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(novoLogin, javax.swing.GroupLayout.PREFERRED_SIZE, 387, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(novoNivelAcesso, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(29, 29, 29)
                                .addComponent(selecionaCliente)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(atualizaCliente)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(removerCliente))
                            .addComponent(jLabel9))
                        .addGap(0, 198, Short.MAX_VALUE))))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(jLabel6)
                .addGap(18, 18, 18)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(campoBuscaLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addComponent(buscarCliente)
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(54, 54, 54)
                        .addComponent(jLabel9)
                        .addGap(18, 18, 18)
                        .addComponent(novoLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(novaSenha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(novoNivelAcesso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(atualizaCliente)
                            .addComponent(selecionaCliente)
                            .addComponent(removerCliente))))
                .addContainerGap(182, Short.MAX_VALUE))
        );

        abasUsuario.addTab("Editar", jPanel3);

        tabelaTransacoes.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "id", "Nome do Cliente", "CPF/CNPJ", "Nome do Produto", "Código do Produto", "Quantidade", "Preço por Unidade", "Valor da Transação", "Desconto", "Data (ano-mês-dia)"
            }
        ));
        jScrollPane2.setViewportView(tabelaTransacoes);

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel8.setText("Edição de Vendas");

        jLabel10.setText("Busque a transação pelo ID:");

        jLabel11.setText("Busque pelo CPF/CNPJ do cliente:");

        jLabel13.setText("Busque pela data: (Entre primeira data e segunda data):");

        comboDiaInicial.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        comboMesInicial.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Jan", "Fev", "Mar", "Abr", "Maio", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez" }));

        comboAnoInicial.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2016", "2015", "2014", "2013", "2012", "2011", "2010", "2009", "2008", "2007", "2006", "2005", "2004", "2003", "2002", "2001", "2000" }));
        comboAnoInicial.setSelectedIndex(3);

        jLabel14.setText("a:");

        comboDiaFinal.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        comboMesFinal.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Jan", "Fev", "Mar", "Abr", "Maio", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez" }));

        comboAnoFinal.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2016", "2015", "2014", "2013", "2012", "2011", "2010", "2009", "2008", "2007", "2006", "2005", "2004", "2003", "2002", "2001", "2000" }));
        comboAnoFinal.setSelectedIndex(3);

        checkData.setText("Busca por data");
        checkData.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkDataActionPerformed(evt);
            }
        });

        checkCPFCNPJ.setText("Busca por CPF/CNPJ");
        checkCPFCNPJ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkCPFCNPJActionPerformed(evt);
            }
        });

        checkID.setText("Busca por ID");
        checkID.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkIDActionPerformed(evt);
            }
        });

        buscarTransacao.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/search.png"))); // NOI18N
        buscarTransacao.setText("Buscar");
        buscarTransacao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buscarTransacaoActionPerformed(evt);
            }
        });

        cancelarBusca.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/cancel.png"))); // NOI18N
        cancelarBusca.setText("Cancelar");
        cancelarBusca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelarBuscaActionPerformed(evt);
            }
        });

        selecionarTransacao.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/edit.png"))); // NOI18N
        selecionarTransacao.setText("Editar/Remover Transações");
        selecionarTransacao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                selecionarTransacaoActionPerformed(evt);
            }
        });

        tabelaCompras.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "id", "Nome do Cliente", "CPF/CNPJ", "Valor da Transação", "Desconto", "Data (ano-mês-dia)"
            }
        ));
        jScrollPane3.setViewportView(tabelaCompras);

        selecionarCompra.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/select.png"))); // NOI18N
        selecionarCompra.setText("Selecionar");
        selecionarCompra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                selecionarCompraActionPerformed(evt);
            }
        });

        removerCompra.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/cancel.png"))); // NOI18N
        removerCompra.setText("Remover");
        removerCompra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removerCompraActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel13)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(comboDiaInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(comboMesInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(comboAnoInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(47, 47, 47)
                                .addComponent(jLabel14)
                                .addGap(45, 45, 45)
                                .addComponent(comboDiaFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(comboMesFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(comboAnoFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel10)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(campoBuscaID, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(campoBuscaCPFCNPJ, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGap(297, 297, 297)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(checkID)
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(checkCPFCNPJ)
                                            .addComponent(checkData))
                                        .addGap(18, 18, 18)
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addGroup(jPanel4Layout.createSequentialGroup()
                                                .addComponent(buscarTransacao, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(selecionarCompra, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(removerCompra, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel4Layout.createSequentialGroup()
                                                .addComponent(cancelarBusca, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(selecionarTransacao, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))))
                            .addComponent(jLabel8))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 1085, Short.MAX_VALUE))
                .addContainerGap())
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 1085, Short.MAX_VALUE)
                    .addContainerGap()))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(jLabel8)
                .addGap(22, 22, 22)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(campoBuscaID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(checkID))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(campoBuscaCPFCNPJ, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(checkCPFCNPJ)))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(selecionarCompra)
                                    .addComponent(buscarTransacao)
                                    .addComponent(removerCompra, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(cancelarBusca)
                                    .addComponent(selecionarTransacao)))))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(comboDiaInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(comboMesInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(comboAnoInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel14)
                            .addComponent(comboDiaFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(comboMesFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(comboAnoFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(checkData))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 176, Short.MAX_VALUE)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                    .addContainerGap(240, Short.MAX_VALUE)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(170, 170, 170)))
        );

        abasUsuario.addTab("Transações", jPanel4);

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel12.setText("Produtos Vendidos");

        comboAnoFinalProduto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2016", "2015", "2014", "2013", "2012", "2011", "2010", "2009", "2008", "2007", "2006", "2005", "2004", "2003", "2002", "2001", "2000" }));
        comboAnoFinalProduto.setSelectedIndex(3);

        comboMesFinalProduto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Jan", "Fev", "Mar", "Abr", "Maio", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez" }));

        comboDiaFinalProduto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        jLabel15.setText("a:");

        comboAnoInicialProduto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2016", "2015", "2014", "2013", "2012", "2011", "2010", "2009", "2008", "2007", "2006", "2005", "2004", "2003", "2002", "2001", "2000" }));
        comboAnoInicialProduto.setSelectedIndex(3);

        comboMesInicialProduto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Jan", "Fev", "Mar", "Abr", "Maio", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez" }));

        comboDiaInicialProduto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        buscarProdutosVendidos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/search.png"))); // NOI18N
        buscarProdutosVendidos.setText("Buscar");
        buscarProdutosVendidos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buscarProdutosVendidosActionPerformed(evt);
            }
        });

        cancelarProdutosVendidos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/cancel.png"))); // NOI18N
        cancelarProdutosVendidos.setText("Cancelar");
        cancelarProdutosVendidos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelarProdutosVendidosActionPerformed(evt);
            }
        });

        tabelaProdutosVendidos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Nome do Produto", "Código do Produto", "Quantidade", "Preço por Unidade", "Data (ano-mês-dia)"
            }
        ));
        jScrollPane4.setViewportView(tabelaProdutosVendidos);

        gerarListaProdutosVendidos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/listaClientes.png"))); // NOI18N
        gerarListaProdutosVendidos.setText("Gerar Relatório");
        gerarListaProdutosVendidos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                gerarListaProdutosVendidosActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(gerarListaProdutosVendidos, javax.swing.GroupLayout.PREFERRED_SIZE, 181, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 1085, Short.MAX_VALUE)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel12)
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(comboDiaInicialProduto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(comboMesInicialProduto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(comboAnoInicialProduto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(66, 66, 66)
                                .addComponent(jLabel15)
                                .addGap(69, 69, 69)
                                .addComponent(comboDiaFinalProduto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(comboMesFinalProduto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(comboAnoFinalProduto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(123, 123, 123)
                .addComponent(buscarProdutosVendidos, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cancelarProdutosVendidos, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addComponent(jLabel12)
                .addGap(52, 52, 52)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboDiaInicialProduto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboMesInicialProduto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboAnoInicialProduto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15)
                    .addComponent(comboDiaFinalProduto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboMesFinalProduto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboAnoFinalProduto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(29, 29, 29)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buscarProdutosVendidos)
                    .addComponent(cancelarProdutosVendidos))
                .addGap(51, 51, 51)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(gerarListaProdutosVendidos)
                .addContainerGap(16, Short.MAX_VALUE))
        );

        abasUsuario.addTab("Produtos Vendidos", jPanel5);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(barraAdministrador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(abasUsuario))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(barraAdministrador, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(abasUsuario, javax.swing.GroupLayout.Alignment.TRAILING)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void adicionarUsuariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_adicionarUsuariosActionPerformed
        abasUsuario.setSelectedIndex(0);
        this.abasUsuario.setEnabledAt(0, true);
        this.abasUsuario.setEnabledAt(1, false);
        this.abasUsuario.setEnabledAt(2, false);
        this.abasUsuario.setEnabledAt(3, false);
    }//GEN-LAST:event_adicionarUsuariosActionPerformed

    private void editarUsuariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editarUsuariosActionPerformed
        abasUsuario.setSelectedIndex(1);
        this.abasUsuario.setEnabledAt(0, false);
        this.abasUsuario.setEnabledAt(2, false);
        this.abasUsuario.setEnabledAt(1, true);
        this.abasUsuario.setEnabledAt(3, false);
    }//GEN-LAST:event_editarUsuariosActionPerformed

    private void editarTransacoesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editarTransacoesActionPerformed
        abasUsuario.setSelectedIndex(2);
        this.abasUsuario.setEnabledAt(0, false);
        this.abasUsuario.setEnabledAt(1, false);
        this.abasUsuario.setEnabledAt(2, true);
        this.abasUsuario.setEnabledAt(3, false);

    }//GEN-LAST:event_editarTransacoesActionPerformed

    private void botaoConfirmarUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoConfirmarUsuarioActionPerformed
        int nivelAcesso = comboNivelAcesso.getSelectedIndex();
        if (campoSenha.getText().equals(confirmaSenha.getText())) {

            if (!campoSenha.getText().equals("") && !confirmaSenha.equals("") && !campoLoginUsuario.equals("")) {
                controladorUsuario.insereUsuario(campoLoginUsuario.getText(), campoSenha.getText(), nivelAcesso);
                JOptionPane.showMessageDialog(null, "Usuário adicionado com sucesso");
            } else {
                JOptionPane.showMessageDialog(null, "Todos os campos precisam ser preenchidos");
            }

            this.campoSenha.setText("");
            this.confirmaSenha.setText("");
            this.campoLoginUsuario.setText("");
            this.comboNivelAcesso.setSelectedIndex(0);
        } else {
            JOptionPane.showMessageDialog(null, "Senha e confirmação não conferem");
        }
    }//GEN-LAST:event_botaoConfirmarUsuarioActionPerformed

    private void cancelarBotaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelarBotaoActionPerformed
        this.campoSenha.setText("");
        this.confirmaSenha.setText("");
        this.campoLoginUsuario.setText("");
        this.comboNivelAcesso.setSelectedIndex(0);
    }//GEN-LAST:event_cancelarBotaoActionPerformed

    private void buscarClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarClienteActionPerformed
        if (campoBuscaLogin.getText().equals("")) {
            usuarios = controladorUsuario.buscaTodosOsUsuarios();
        } else {
            usuarios = controladorUsuario.buscaUsuariosPorLogin(campoBuscaLogin.getText());
        }

        modelUsuarios.setNumRows(0);


        for (int i = 0; i < usuarios.size(); i++) {
            Vector vec = new Vector();
            vec.add(0, usuarios.get(i).getLogin());
            vec.add(1, usuarios.get(i).getSenha());
            vec.add(2, usuarios.get(i).getNivelAcesso());
            modelUsuarios.addRow(vec);
        }

        this.repaint();

    }//GEN-LAST:event_buscarClienteActionPerformed

    private void atualizaClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_atualizaClienteActionPerformed

        if (!novoNivelAcesso.getText().equals("") && !novoLogin.getText().equals("") && !novaSenha.equals("")) {
            controladorUsuario.atualizaUsuario(novoLogin.getText(), novaSenha.getText(), Integer.parseInt(novoNivelAcesso.getText()), loginSelecionado);
            JOptionPane.showMessageDialog(this, "Usuário atualizado com sucesso", "Warning", JOptionPane.WARNING_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(this, "Campos precisam ser preenchidos", null, JOptionPane.OK_OPTION);

        }
    }//GEN-LAST:event_atualizaClienteActionPerformed

    private void selecionaClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selecionaClienteActionPerformed
        try {
            int selecionado = tabelaUsuarios.getSelectedRow();
            Usuario usuarioSelecionado = usuarios.get(selecionado);
            novoLogin.setText(usuarioSelecionado.getLogin());
            novaSenha.setText(usuarioSelecionado.getSenha());
            novoNivelAcesso.setText(String.valueOf(usuarioSelecionado.getNivelAcesso()));
            loginSelecionado = usuarioSelecionado.getLogin();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Um cliente deve ser selecionado na tabela", null, JOptionPane.OK_OPTION);

        }
    }//GEN-LAST:event_selecionaClienteActionPerformed

    private void removerClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removerClienteActionPerformed
        /*if (!cpfSelecionado.equals("") && cpfSelecionado != null && tabelaUsuarios.getSelectedRow() != -1) {
         controladorCliente.deletaClientesPorCPFCNPJ(cpfSelecionado);
         JOptionPane.showMessageDialog(this, "Cliente removido com sucesso", "Warning", JOptionPane.WARNING_MESSAGE);
         } else {
         JOptionPane.showMessageDialog(this, "Um cliente deve ser selecionado na Tabela", null, JOptionPane.OK_OPTION);
         }*/
    }//GEN-LAST:event_removerClienteActionPerformed

    private void checkIDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkIDActionPerformed
        if (checkID.isSelected()) {
            this.campoBuscaCPFCNPJ.setEnabled(false);
            this.campoBuscaID.setEnabled(true);

            this.comboAnoFinal.setEnabled(false);
            this.comboAnoInicial.setEnabled(false);
            this.comboMesFinal.setEnabled(false);
            this.comboMesInicial.setEnabled(false);
            this.comboDiaFinal.setEnabled(false);
            this.comboDiaInicial.setEnabled(false);

            this.checkCPFCNPJ.setSelected(false);
            this.checkData.setSelected(false);
        }
    }//GEN-LAST:event_checkIDActionPerformed

    private void checkCPFCNPJActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkCPFCNPJActionPerformed
        if (checkCPFCNPJ.isSelected()) {
            this.campoBuscaCPFCNPJ.setEnabled(true);
            this.campoBuscaID.setEnabled(false);

            this.comboAnoFinal.setEnabled(false);
            this.comboAnoInicial.setEnabled(false);
            this.comboMesFinal.setEnabled(false);
            this.comboMesInicial.setEnabled(false);
            this.comboDiaFinal.setEnabled(false);
            this.comboDiaInicial.setEnabled(false);

            this.checkID.setSelected(false);
            this.checkData.setSelected(false);
        }
    }//GEN-LAST:event_checkCPFCNPJActionPerformed

    private void checkDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkDataActionPerformed
        if (checkData.isSelected()) {
            this.campoBuscaCPFCNPJ.setEnabled(false);
            this.campoBuscaID.setEnabled(false);

            this.comboAnoFinal.setEnabled(true);
            this.comboAnoInicial.setEnabled(true);
            this.comboMesFinal.setEnabled(true);
            this.comboMesInicial.setEnabled(true);
            this.comboDiaFinal.setEnabled(true);
            this.comboDiaInicial.setEnabled(true);

            this.checkCPFCNPJ.setSelected(false);
            this.checkID.setSelected(false);
        }
    }//GEN-LAST:event_checkDataActionPerformed

    private void buscarTransacaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarTransacaoActionPerformed
        int diaInicial = dias[comboDiaInicial.getSelectedIndex()];
        int diaFinal = dias[comboDiaFinal.getSelectedIndex()];
        int mesInicial = meses[comboMesInicial.getSelectedIndex()];
        int mesFinal = meses[comboMesFinal.getSelectedIndex()];
        int anoInicial = anos[comboAnoInicial.getSelectedIndex()];
        int anoFinal = anos[comboAnoFinal.getSelectedIndex()];

        if (checkID.isSelected()) {
            compras = controladorCompras.buscaCompraPorID(Integer.parseInt(campoBuscaID.getText()));
        } else if (checkCPFCNPJ.isSelected()) {
            compras = controladorCompras.buscaCompraPorCPF_CNPJ(campoBuscaCPFCNPJ.getText());
        } else if (checkData.isSelected()) {
            compras = controladorCompras.buscaCompraPorData(new Date(anoInicial - 1900, mesInicial - 1, diaInicial), new Date(anoFinal - 1900, mesFinal - 1, diaFinal));
        } else {
            compras = controladorCompras.buscaTodasAsCompras();
        }

        modelCompras.setNumRows(0);


        for (int i = 0; i < compras.size(); i++) {
            Vector vec = new Vector();
            vec.add(0, compras.get(i).getId());
            vec.add(1, compras.get(i).getNomeDoCliente());
            vec.add(2, compras.get(i).getCpf_cnpjDoCliente());
            vec.add(3, compras.get(i).getPrecoTotal());
            vec.add(4, compras.get(i).getDescontoTotal());
            vec.add(5, compras.get(i).getDataDaCompra());
            modelCompras.addRow(vec);
        }

        this.repaint();
    }//GEN-LAST:event_buscarTransacaoActionPerformed

    private void cancelarBuscaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelarBuscaActionPerformed

        modelTransacoes.setNumRows(0);
        modelCompras.setNumRows(0);
        this.campoBuscaCPFCNPJ.setEnabled(false);
        this.campoBuscaID.setEnabled(false);

        this.comboAnoFinal.setEnabled(false);
        this.comboAnoInicial.setEnabled(false);
        this.comboMesFinal.setEnabled(false);
        this.comboMesInicial.setEnabled(false);
        this.comboDiaFinal.setEnabled(false);
        this.comboDiaInicial.setEnabled(false);

        this.checkData.setSelected(false);
        this.checkCPFCNPJ.setSelected(false);
        this.checkID.setSelected(false);

    }//GEN-LAST:event_cancelarBuscaActionPerformed

    private void selecionarTransacaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selecionarTransacaoActionPerformed
        try {
            int selecionado = tabelaTransacoes.getSelectedRow();
            Transacoes transacaoSelecionada = transacoes.get(selecionado);
            PainelEdicaoTransacoes painelEdicaoTransacoes = new PainelEdicaoTransacoes(transacaoSelecionada, selecionado);
            painelEdicaoTransacoes.setVisible(true);
            painelEdicaoTransacoes.setAlwaysOnTop(true);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Uma transação deve ser selecionado na tabela", null, JOptionPane.OK_OPTION);
        }
    }//GEN-LAST:event_selecionarTransacaoActionPerformed

    private void selecionarCompraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selecionarCompraActionPerformed
        try {
            compraSelecionada = compras.get(tabelaCompras.getSelectedRow());

            transacoes = controladorTransacoes.buscaTransacoesPorIDDaCompra(compraSelecionada.getId());

            modelTransacoes.setNumRows(0);
            for (int i = 0; i < transacoes.size(); i++) {
                Vector vec = new Vector();
                vec.add(0, transacoes.get(i).getIdDaTransacao());
                vec.add(1, transacoes.get(i).getNomeDoCliente());
                vec.add(2, transacoes.get(i).getCpf_cnpjCliente());
                vec.add(3, transacoes.get(i).getNomeDoProduto());
                vec.add(4, transacoes.get(i).getCodigoDoProduto());
                vec.add(5, transacoes.get(i).getQuantidadeVendidade());
                vec.add(6, transacoes.get(i).getPrecoPorUnidade());
                vec.add(7, transacoes.get(i).getValorTotalDaTransacao());
                vec.add(8, transacoes.get(i).getDescontoDado());
                vec.add(9, transacoes.get(i).getData());
                modelTransacoes.addRow(vec);
            }

        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Deve-se selecionar uma compra na tabela", null, JOptionPane.OK_OPTION);
        }
    }//GEN-LAST:event_selecionarCompraActionPerformed

    private void removerCompraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removerCompraActionPerformed
        try {
            int selecionado = tabelaCompras.getSelectedRow();
            Compra compraSelecionada = compras.get(selecionado);
            controladorCompras.deletaCompra(compraSelecionada);
            controladorTransacoes.deletaTransacaoPorIdDaCompra(compraSelecionada);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Uma transação deve ser selecionado na tabela", null, JOptionPane.OK_OPTION);
        }
    }//GEN-LAST:event_removerCompraActionPerformed

    private void produtosVendidosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_produtosVendidosActionPerformed
        abasUsuario.setSelectedIndex(3);
        this.abasUsuario.setEnabledAt(0, false);
        this.abasUsuario.setEnabledAt(1, false);
        this.abasUsuario.setEnabledAt(2, false);
        this.abasUsuario.setEnabledAt(3, true);
    }//GEN-LAST:event_produtosVendidosActionPerformed

    private void cancelarProdutosVendidosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelarProdutosVendidosActionPerformed
        this.modelProdutosVendidos.setNumRows(0);
    }//GEN-LAST:event_cancelarProdutosVendidosActionPerformed

    private void buscarProdutosVendidosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarProdutosVendidosActionPerformed
        int diaInicial = dias[comboDiaInicialProduto.getSelectedIndex()];
        int diaFinal = dias[comboDiaFinalProduto.getSelectedIndex()];
        int mesInicial = meses[comboMesInicialProduto.getSelectedIndex()];
        int mesFinal = meses[comboMesFinalProduto.getSelectedIndex()];
        int anoInicial = anos[comboAnoInicialProduto.getSelectedIndex()];
        int anoFinal = anos[comboAnoFinalProduto.getSelectedIndex()];
        listaProdutosVendidos = controladorTransacoes.buscaTransacoesPorData(new Date(anoInicial - 1900, mesInicial - 1, diaInicial), new Date(anoFinal - 1900, mesFinal - 1, diaFinal));
        
        modelProdutosVendidos.setNumRows(0);
            for (int i = 0; i < listaProdutosVendidos.size(); i++) {
                Vector vec = new Vector();
                vec.add(0, listaProdutosVendidos.get(i).getNomeDoProduto());
                vec.add(1, listaProdutosVendidos.get(i).getCodigoDoProduto());
                vec.add(2, listaProdutosVendidos.get(i).getQuantidadeVendidade());
                vec.add(3, listaProdutosVendidos.get(i).getPrecoPorUnidade());
                vec.add(4, listaProdutosVendidos.get(i).getData());
                modelProdutosVendidos.addRow(vec);
            }

        this.repaint();
        
    }//GEN-LAST:event_buscarProdutosVendidosActionPerformed

    private void gerarListaProdutosVendidosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gerarListaProdutosVendidosActionPerformed
        if (modelProdutosVendidos.getRowCount()>0 && listaProdutosVendidos.size()>0) {
            ListaProdutosVendidosPorDataPDF transacaoPDF = new ListaProdutosVendidosPorDataPDF(listaProdutosVendidos);
            JOptionPane.showMessageDialog(this, "Relatório de transação gerado com sucesso. Cheque-o em C:ArquivosPDF/Transacoes/", "Warning", JOptionPane.WARNING_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(this, "Nenhum produto foi vendido nesta data", null, JOptionPane.OK_OPTION);
        }
    }//GEN-LAST:event_gerarListaProdutosVendidosActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTabbedPane abasUsuario;
    private javax.swing.JButton adicionarUsuarios;
    private javax.swing.JButton atualizaCliente;
    private javax.swing.JToolBar barraAdministrador;
    private javax.swing.JButton botaoConfirmarUsuario;
    private javax.swing.JButton buscarCliente;
    private javax.swing.JButton buscarProdutosVendidos;
    private javax.swing.JButton buscarTransacao;
    private javax.swing.JTextField campoBuscaCPFCNPJ;
    private javax.swing.JTextField campoBuscaID;
    private javax.swing.JTextField campoBuscaLogin;
    private javax.swing.JTextField campoLoginUsuario;
    private javax.swing.JTextField campoSenha;
    private javax.swing.JButton cancelarBotao;
    private javax.swing.JButton cancelarBusca;
    private javax.swing.JButton cancelarProdutosVendidos;
    private javax.swing.JCheckBox checkCPFCNPJ;
    private javax.swing.JCheckBox checkData;
    private javax.swing.JCheckBox checkID;
    private javax.swing.JComboBox comboAnoFinal;
    private javax.swing.JComboBox comboAnoFinalProduto;
    private javax.swing.JComboBox comboAnoInicial;
    private javax.swing.JComboBox comboAnoInicialProduto;
    private javax.swing.JComboBox comboDiaFinal;
    private javax.swing.JComboBox comboDiaFinalProduto;
    private javax.swing.JComboBox comboDiaInicial;
    private javax.swing.JComboBox comboDiaInicialProduto;
    private javax.swing.JComboBox comboMesFinal;
    private javax.swing.JComboBox comboMesFinalProduto;
    private javax.swing.JComboBox comboMesInicial;
    private javax.swing.JComboBox comboMesInicialProduto;
    private javax.swing.JComboBox comboNivelAcesso;
    private javax.swing.JTextField confirmaSenha;
    private javax.swing.JButton editarTransacoes;
    private javax.swing.JButton editarUsuarios;
    private javax.swing.JButton gerarListaProdutosVendidos;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTextField novaSenha;
    private javax.swing.JTextField novoLogin;
    private javax.swing.JTextField novoNivelAcesso;
    private javax.swing.JButton produtosVendidos;
    private javax.swing.JButton removerCliente;
    private javax.swing.JButton removerCompra;
    private javax.swing.JButton selecionaCliente;
    private javax.swing.JButton selecionarCompra;
    private javax.swing.JButton selecionarTransacao;
    private javax.swing.JTable tabelaCompras;
    private javax.swing.JTable tabelaProdutosVendidos;
    private javax.swing.JTable tabelaTransacoes;
    private javax.swing.JTable tabelaUsuarios;
    // End of variables declaration//GEN-END:variables
}
